package ajaxjs.data.ext.fields;

import ajaxjs.data.entry.type._String;

public class Filepath extends _String{
	public String superJoinField = "video";
	public Filepath(){
		this.label = "源地址";
	}
	
	/**
	 * 如果用户没有输入 intro，则自动读取标题作为 intro；如果以后有输入 intro，则读取 intro
	 * @return
	 */
	public String formatter(){
		String js = "if(!item.filepath)return;"
				+ "var url = 'http://221.4.246.90:1935/vod/vod/{0}/mp4:{1}l.mp4/playlist.m3u8';"
				+ "var arr = item.filepath.split('/');"
				+ "if(arr && arr.length > 1){"
				+ "		url = url.format(arr[0], arr[1].replace(/\\.\\w+$/, ''));"
				+ "		item.filepath = url;"
				+ "}";
		return js; 
	}
}